import time
import matplotlib.pyplot as plt
import serial
import binascii
from dvg_ringbuffer import RingBuffer
import numpy as np
import threading

from GlobVarLock import GlobVarLocker as glob

from IMUDataRecord import IMUDataRecorder
from IMUDataExtract import IMUDataExtracter
from IMUDataOutput import IMUDataOutputer
from IMUDataPlot import IMUDataPloter


def main():
    print('start')
    threads = []

    glob.init(5000) # (orin data, )

    thread_IMUDataRecorder = IMUDataRecorder('COM7', 115200)
    thread_IMUDataExtracter = IMUDataExtracter()
    thread_IMUDataOutputer = IMUDataOutputer()
    thread_IMUDataPloter = IMUDataPloter()

    thread_IMUDataRecorder.start()
    thread_IMUDataExtracter.start()
    thread_IMUDataOutputer.start()
    thread_IMUDataPloter.start()

    threads.append(thread_IMUDataRecorder)
    threads.append(thread_IMUDataExtracter)
    threads.append(thread_IMUDataOutputer)
    threads.append(thread_IMUDataPloter)

    # 等待所有线程完成
    for t in threads:
        t.join()
    print("退出主线程")

if __name__ == '__main__':
    main()





